/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-05-04 09:50:21
 * @LastEditTime : 2023-08-27 15:32:24
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\CostMonth.jsx
 * @Description  :
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import {
    AddDataButton,
    ModDataButton,
    DelDataButton,
    OpenExcelButton,
    ExecuteButton,
    MoreActionsButton,
} from '../Common/options'
import dayjs from 'dayjs'
import { OrganizationListByPingJi } from '../Common/Conversion'

// isInclude: true,
// NotIdentityLevel: '1,3'
// getOrganizationListByPingJ

export const CostMonth = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1, isInclude: true, NotIdentityLevel: '1,3' },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission.findIndex(v => v.uuid === '281c1308-570b-4722-9835-4d44d5e3b719') !== -1 && (
                <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />
            ),
        ],
        columns: [
            { ...commonTableList.SearchSort, selectType: 'CostMonth' },
            commonTableList.uuid,
            {
                ...commonTableList.organizationUuid,
                valueEnum: await OrganizationListByPingJi('?IsInclude=true&NotIdentityLevel=1,3'),
            },
            {
                dataIndex: 'eventDate',
                title: '申报年月',
                valueType: 'Date',
                ellipsis: true,
                rules: true,
                width: 200,
                hideInSearch: true,
                render: (_, e) => <div>{dayjs(e.eventDate).format('YYYY-MM-DD')}</div>,
            },
            {
                dataIndex: 'createTime',
                title: '填报日期',
                valueType: 'Date',
                ellipsis: true,
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            commonTableList.StartDate,
            commonTableList.EndDate,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 240,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { uuid } = record
                    return [
                        Permission.findIndex(v => v.uuid === '22ee44b7-0ba8-420c-9c6b-18c5a4ef4002') !== -1 && (
                            <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />
                        ),
                        Permission.findIndex(v => v.uuid === 'e74afa72-1a13-4519-93d1-e9bf9501bdf3') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                        Permission.findIndex(v => v.uuid === '2d8c0c31-d145-4dfa-8684-d0fc409ba295') !== -1 && (
                            <MoreActionsButton
                                key="more"
                                title="明细操作"
                                data={{
                                    record,
                                    actionRef,
                                    Permission,
                                    OptionsEvent,
                                    header: data.columns,
                                    CostMonthA01: {
                                        type: 'OpenExcel',
                                        smallTitle: '项目明细',
                                        save: true,
                                        submit: true,
                                        CostMonthUuid: uuid,
                                        url: 'getCostMonthCostMonthDetailAcross',
                                        pos: 'posCostMonthCostMonthDetailAcross',
                                    },
                                    CostMonthA02: {
                                        type: 'OpenExcel',
                                        smallTitle: '公司汇总',
                                        save: true,
                                        submit: true,
                                        CostMonthUuid: uuid,
                                        url: 'getCostMonthFilialeCostMonthDetail',
                                        pos: 'posCostMonthFilialeCostMonthDetail',
                                    },
                                    CostMonthA03: {
                                        type: 'OpenExcel',
                                        smallTitle: '工建汇总',
                                        save: true,
                                        CostMonthUuid: uuid,
                                        url: 'getCostMonthZFilialeCostMonthDetail',
                                    },
                                    CostMonthA04: {
                                        type: 'ExecuteButton',
                                        smallTitle: '清除明细数据',
                                        url: 'posCostMonthDelCostMonth',
                                        path: [uuid],
                                        tips: '明细数据已清除!',
                                        fun: 'delete',
                                    },
                                    CostMonthA05: {
                                        type: 'OpenExcel',
                                        smallTitle: '计划成本分公司明细',
                                        save: true,
                                        submit: true,
                                        CostMonthUuid: uuid,
                                        url: 'getCostMonthGetCostMonthPlanDetails',
                                        pos: 'posCostMonthUploadCostMonthPlanDetails',
                                    },
                                    ClearMonthA05: {
                                        type: 'ExecuteButton',
                                        smallTitle: '清除计划成本分公司明细',
                                        url: 'posCostMonthDelCostMonthPlanDetails',
                                        path: [uuid],
                                        tips: '明细数据已清除!',
                                        fun: 'delete',
                                    },
                                    CostMonthA06: {
                                        type: 'OpenExcel',
                                        smallTitle: '计划成本分公司汇总表',
                                        save: true,
                                        submit: true,
                                        CostMonthUuid: uuid,
                                        url: 'getCostMonthGetCostMonthPlanGroup',
                                        pos: 'posCostMonthUploadCostMonthPlanGroup',
                                    },
                                    ClearMonthA06: {
                                        type: 'ExecuteButton',
                                        smallTitle: '清除计划成本分公司汇总表',
                                        url: 'posCostMonthDelCostMonthPlanGroup',
                                        path: [uuid],
                                        tips: '明细数据已清除!',
                                        fun: 'delete',
                                    },
                                    CostMonthA07: {
                                        type: 'OpenExcel',
                                        smallTitle: '计划成本总公司汇报表',
                                        save: true,
                                        submit: true,
                                        CostMonthUuid: uuid,
                                        url: 'getCostMonthGetCostMonthPlanGroupZG',
                                        pos: 'posCostMonthUploadCostMonthPlanGroupZG',
                                    },
                                    ClearMonthA07: {
                                        type: 'ExecuteButton',
                                        smallTitle: '清除计划成本总公司汇报表',
                                        url: 'posCostMonthDelCostMonthPlanGroupZG',
                                        path: [uuid],
                                        tips: '明细数据已清除!',
                                        fun: 'delete',
                                    },
                                }}
                                items={[
                                    Permission.findIndex(v => v.uuid === '6c8fddf0-4930-4ce1-924a-75ccd632a039') !==
                                        -1 && {
                                        key: 'CostMonthA01',
                                        label: '项目明细',
                                    },
                                    Permission.findIndex(v => v.uuid === '41095ad0-572e-4d4e-b31d-62ce7373d09d') !==
                                        -1 && {
                                        key: 'CostMonthA02',
                                        label: '公司汇总',
                                    },
                                    Permission.findIndex(v => v.uuid === '67f834b1-25f8-4043-aa8d-08164d0ba445') !==
                                        -1 && {
                                        key: 'CostMonthA03',
                                        label: '工建汇总',
                                    },
                                    Permission.findIndex(v => v.uuid === '7a413cbe-90a5-4c4d-bedd-41dc3eba3cfc') !==
                                        -1 && {
                                        key: 'CostMonthA04',
                                        label: '清除明细数据',
                                        danger: true,
                                    },
                                    Permission.findIndex(v => v.uuid === '69ef395d-c847-4b76-8c9a-afb49c6b2031') !==
                                        -1 && {
                                        key: 'CostMonthA05',
                                        label: '计划成本分公司明细',
                                    },
                                    Permission.findIndex(v => v.uuid === 'c1ae3503-09cc-418d-9876-f6f84b066579') !==
                                        -1 && {
                                        key: 'ClearMonthA05',
                                        label: '清除计划成本分公司明细',
                                        danger: true,
                                    },
                                    Permission.findIndex(v => v.uuid === '9ef3ece3-cba4-4868-a5c5-dae3c2a91d45') !==
                                        -1 && {
                                        key: 'CostMonthA06',
                                        label: '计划成本分公司汇总表',
                                    },
                                    Permission.findIndex(v => v.uuid === 'b2da3bfc-68bd-4f74-bcf9-ad6e400c57ca') !==
                                        -1 && {
                                        key: 'ClearMonthA06',
                                        label: '清除计划成本分公司汇总表',
                                        danger: true,
                                    },
                                    Permission.findIndex(v => v.uuid === '5f81b4fe-fcfa-4f72-9e63-0c603832ec70') !==
                                        -1 && {
                                        key: 'CostMonthA07',
                                        label: '计划成本总公司汇报表',
                                    },
                                    Permission.findIndex(v => v.uuid === 'dcf7e27b-6e29-49c8-98cf-b583f24b607a') !==
                                        -1 && {
                                        key: 'ClearMonthA07',
                                        label: '清除计划成本总公司汇报表',
                                        danger: true,
                                    },
                                ]}
                            />
                        ),
                    ]
                },
            },
        ],
    }

    return data
}
